 call ana 7

procedure ana .seltab
select .seltab
split[1] = Extract rows where column (text)... Filename contains F20
select .seltab
split[2] = Extract rows where column (text)... Filename contains F28
select .seltab
split[3] = Extract rows where column (text)... Filename contains F40
select .seltab
split[4] = Extract rows where column (text)... Filename contains F60
select .seltab
split[5] = Extract rows where column (text)... Filename contains M15
select .seltab
split[6] = Extract rows where column (text)... Filename contains M40
select .seltab
split[7] = Extract rows where column (text)... Filename contains M56
select .seltab
split[8] = Extract rows where column (text)... Filename contains M66

for .i from 1 to 8
	.id = split[.i]
	call analyze_realVoice .id
	.anares[.i] = analyze_realVoice.res
	.comres[.i] = analyze_realVoice.res2
	.anapool[.i] = analyze_realVoice.col
	select .comres[.i]
	.comsplitI[.i] = Extract rows where column (text)... Vowel "is equal to" i
	data$ = Report difference (Student t)... F1r_fm F1r_hm 0.025
	data$ = data$ + "'newline$'"
	name$ = "i_2-in-1_'.i'.txt"
	data$ > C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'name$'
	data2$ = Report difference (Student t)... F1b_fm F1b_hm 0.025
	data2$ >> C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'name$'
	select .comres[.i]
	.comsplita[.i] = Extract rows where column (text)... Vowel "is equal to" a
	dataa$ = Report difference (Student t)... F1r_fm F1r_hm 0.025
	dataa$ = dataa$ + "'newline$'"
	namea$ = "a_2-in-1_'.i'.txt"
	dataa$ > C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'namea$'
	dataa2$ = Report difference (Student t)... F1b_fm F1b_hm 0.025
	dataa2$ >> C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'namea$'
	select .comres[.i]
	.comsplitu[.i] = Extract rows where column (text)... Vowel "is equal to" u
	datau$ = Report difference (Student t)... F1r_fm F1r_hm 0.025
	datau$ = datau$ + "'newline$'"
	nameu$ = "u_2-in-1_'.i'.txt"
	datau$ > C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'nameu$'
	datau2$ = Report difference (Student t)... F1b_fm F1b_hm 0.025
	datau2$ >> C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'nameu$'
	if .i = 4
		select .comres[.i]
		.comsplitI[.i] = Extract rows where column (text)... Vowel "is equal to" o
		datao$ = Report difference (Student t)... F1r_fm F1r_hm 0.025
		datao$ = datao$ + "'newline$'"
		nameo$ = "o_2-in-1_'.i'.txt"
		datao$ > C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'nameo$'
		datao2$ = Report difference (Student t)... F1b_fm F1b_hm 0.025
		datao2$ >> C:\Users\dondencio\praat-algorithm-comparison\scripts\tables\analyzeResults\'nameo$'
	endif
endfor

endproc

procedure analyze_realVoice .tableid

	.res = Create Table with column names... analyzeResults 0 F1r F1b F2r F2b F3r F3b ErrorValRAll ErrorValBAll ErrorValRTwo ErrorValBTwo Vowel Filename
	.res2 = Create Table with column names... combineResults 0 F1r_hm F1b_hm F2r_hm F2b_hm F3r_hm F3b_hm F1r_fm F1b_fm F2r_fm F2b_fm F3r_fm F3b_fm Vowel Filename
	select .tableid
	rows = Get number of rows
	end = (rows/2)-1
	for .i from 0 to (rows/2)-1
		select .tableid
		tmp = .i*2
		f1r_fm = Get value...  tmp+1 F1r
		f1r_hm = Get value... tmp+2 F1r
		f1r_diff = (log10(f1r_fm) - log10(f1r_hm))^2

		f1b_fm = Get value...  tmp+1 F1b
		f1b_hm = Get value... tmp+2 F1b
		f1b_diff = (log10(f1b_fm) - log10(f1b_hm))^2

		f2r_fm = Get value...  tmp+1 F2r
		f2r_hm = Get value... tmp+2 F2r
		f2r_diff = (log10(f2r_fm) - log10(f2r_hm))^2

		f2b_fm = Get value...  tmp+1 F2b
		f2b_hm = Get value... tmp+2 F2b
		f2b_diff = (log10(f2b_fm) - log10(f2b_hm))^2

		f3r_fm = Get value...  tmp+1 F3r
		f3r_hm = Get value... tmp+2 F3r
		f3r_diff = (log10(f3r_fm) - log10(f3r_hm))^2

		f3b_fm = Get value...  tmp+1 F3b
		f3b_hm = Get value... tmp+2 F3b
		f3b_diff = (log10(f3b_fm) - log10(f3b_hm))^2

		ipa$ = Get value... tmp+1 Vowel
		name$ = Get value... tmp+1 Filename

		select .res
		Append row
		Set numeric value... .i+1 F1r sqrt(f1r_diff)*10
		Set numeric value... .i+1 F1b sqrt(f1b_diff)*10
		Set numeric value... .i+1 F2r sqrt(f2r_diff)*10
		Set numeric value... .i+1 F2b sqrt(f2b_diff)*10
		Set numeric value... .i+1 F3r sqrt(f3r_diff)*10
		Set numeric value... .i+1 F3b sqrt(f3b_diff)*10

		diff_error_r_all = sqrt(f1r_diff + f2r_diff + f3r_diff)*10
		diff_error_b_all = sqrt(f1b_diff + f2b_diff + f3b_diff)*10

		Set numeric value... .i+1 ErrorValRAll diff_error_r_all
		Set numeric value... .i+1 ErrorValBAll diff_error_b_all

		diff_error_r_two = sqrt(f1r_diff + f2r_diff)*10
		diff_error_b_two = sqrt(f1b_diff + f2b_diff)*10

		Set numeric value... .i+1 ErrorValRTwo diff_error_r_two
		Set numeric value... .i+1 ErrorValBTwo diff_error_b_two

		Set string value... .i+1 Vowel 'ipa$'
		Set string value... .i+1 Filename 'name$'

		select .res2
		Append row
		Set numeric value... .i+1 F1r_fm f1r_fm
		Set numeric value... .i+1 F1b_fm f1b_fm
		Set numeric value... .i+1 F2r_fm f2r_fm
		Set numeric value... .i+1 F2b_fm f2b_fm
		Set numeric value... .i+1 F3r_fm f3r_fm
		Set numeric value... .i+1 F3b_fm f3b_fm

		Set numeric value... .i+1 F1r_hm f1r_hm
		Set numeric value... .i+1 F1b_hm f1b_hm
		Set numeric value... .i+1 F2r_hm f2r_hm
		Set numeric value... .i+1 F2b_hm f2b_hm
		Set numeric value... .i+1 F3r_hm f3r_hm
		Set numeric value... .i+1 F3b_hm f3b_hm

		Set string value... .i+1 Vowel 'ipa$'
		Set string value... .i+1 Filename 'name$'
	endfor
	select .res
	.col = Collapse rows... Vowel "" "F1r F1b F2r F2b ErrorValRAll ErrorValBAll ErrorValRTwo ErrorValBTwo" "" "" 
endproc